class IUP_GAUGE
-- Creates a Gauge control. Shows a percent value that can be updated to 
-- simulate a progression. It inherits from IUP_CANVAS.
--
-- Callbacks:
--
-- MAP_CB, UNMAP_CB, DESTROY_CB: common callbacks are supported.
--
-- Notes:
--
-- To replace a IUP_PROGRESS_BAR by a IUP_GAUGE you should set 
-- set_raster_size=200x30 and set_show_text=False.
	
inherit
	IUP_CANVAS
		redefine
			set_size		
		end
	IUP_WIDGET_FGCOLOR
		redefine
			set_rgb_foreground_color
		end
	IUP_WIDGET_FLAT
	IUP_WIDGET_PADDING

create {ANY}
	gauge

feature {ANY}

	gauge
		local
			a_gauge: POINTER
		do
			a_gauge := int_gauge

			set_widget(a_gauge)
		end

	-- Attributes

	set_dashed (state: BOOLEAN)
		-- Changes the style of the gauge for a dashed pattern. Default=False.
		do
			iup_open.set_attribute(Current, "DASHED", boolean_to_yesno(state))
		end

	set_rgb_foreground_color (red: INTEGER; green: INTEGER; blue: INTEGER)
		-- Controls the gauge and text color. The default is "64 96 192".
		do
			Precursor (red, green, blue)
		end

	set_max (value: REAL)
		-- (non inheritable): Contains the maximum value. Default is "1".
		do
			iup_open.set_attribute(Current, "MAX", value.to_string)
		end

	set_min (value: REAL)
		-- (non inheritable): Contains the minimum value. Default is "0".
		do
			iup_open.set_attribute(Current, "MIN", value.to_string)
		end

	set_horizontal_orientation
		-- (creation only): Horizontal goes from left to right. Width and height 
		-- are swapped when orientation is set. This is the default value.
		do
			iup_open.set_attribute(Current, "ORIENTATION", "HORIZONTAL")
		end

	set_vertical_orientation
		-- (creation only): Vertical from bottom to top. Width and height are 
		-- swapped when orientation is set.
		do
			iup_open.set_attribute(Current, "ORIENTATION", "VERTICAL")
		end

	set_show_text (state: BOOLEAN)
		-- Indicates if the text inside the Gauge is to be shown or not. If the 
		-- gauge is dashed the text is never shown. Default: "True".
		do
			iup_open.set_attribute(Current, "SHOWTEXT", boolean_to_yesno(state))
		end

	set_size (width: INTEGER; height: INTEGER)
		-- (non inheritable): The initial size is "120x14".
		do
			Precursor (width, height)
		end

	set_automatic_layout
		-- Set to allow the automatic layout use smaller values.
		do
			iup_open.set_attribute_null(Current, "SIZE")
		end

	set_text (value: STRING)
		-- (non inheritable): Contains a text to be shown inside the Gauge when 
		-- set_show_text=True.	
		do
			iup_open.set_attribute(Current, "TEXT", value)
		end

	set_use_percent
		-- The percentage calculated from VALUE will be used. If the gauge is 
		-- dashed the text is never shown.
		do
			iup_open.set_attribute_null(Current, "TEXT")
		end

	set_value (value: REAL)
		-- (non inheritable): Contains a number between "MIN" and "MAX", 
		-- controlling the current position.
		do
			iup_open.set_attribute(Current, "VALUE", value.to_string)
		end
	
feature {}

	-- Internals
	
	int_gauge: POINTER
		external "plug_in"
      alias "{
         location: "${sys}/plugins"
         module_name: "iup"
         feature_name: "IupGauge()"
         }"
      end

end -- class IUP_GAUGE

-- The MIT License (MIT)

-- Copyright (c) 2019 by German A. Arias

-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in 
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
